using System;
using System.Diagnostics.Contracts;
using System.Runtime.Serialization;

namespace OpenWaves.ActivityFeed
{
    [DataContract]
    public class Post : UpdateContent
    {
        protected Post()
        {            
        }

        public Post(string text)
        {
            Contract.Requires<ArgumentNullException>(string.IsNullOrEmpty(text) == false);
            this.Text = text;
        }

        [DataMember]
        public string Text { get; private set; }

        public bool Equals(Post other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return Equals(other.Text, this.Text);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof (Post)) return false;
            return this.Equals((Post) obj);
        }

        public override int GetHashCode()
        {
            return this.Text.GetHashCode();
        }
    }
}